package cfca.paperless.client.servlet._4_manager._4_06_UploadSealLog;

import java.util.ArrayList;
import java.util.List;

import cfca.paperless.client.bean.SealLogBean;
import cfca.paperless.client.servlet.PaperlessConfig;
import cfca.paperless.client.servlet.PaperlessManagerClient;
import cfca.paperless.client.util.PaperlessUtil;
import cfca.paperless.client.util.StringUtil;

/**
 * @Description 2.1 自动化制章接口（测试用例）
 * @Author dell
 * @Date 2016-5-13
 * @CodeReviewer TODO
 */
public class UploadSealLogTest01 {

    public static void main(String[] args) throws Exception {
        try {
            PaperlessManagerClient clientBean = new PaperlessManagerClient(PaperlessConfig.managerUrl, 10000, 60000);// 无纸化管理接口的访问URL
            
            String sealCode = "yz201804457754378";
            String sealType = "1";// 1：普通签章；2：场景签章，默认1
            String sealType01 = "2";
            String functionType = "sealAutoPdf";//默认sealAutoPdf
            String bizTypeCode = "bizTypeCode";// 业务类型，比如：开户、开通网银
            String fileHash = "fileHash";
            String timestampUsed = "0";// 是否使用时间戳，0：未使用；1：使用
            //日志列表
            List<SealLogBean> sealLogBeans = new ArrayList<SealLogBean>();
            SealLogBean sealLogBean = new SealLogBean(sealCode, sealType, functionType, bizTypeCode, timestampUsed);
            sealLogBean.setFileHash(fileHash);
            sealLogBeans.add(sealLogBean);
            SealLogBean sealLogBean01 = new SealLogBean(sealCode, sealType01, functionType, bizTypeCode, timestampUsed);
            sealLogBean01.setFileHash(fileHash);
            sealLogBeans.add(sealLogBean01);
            // 操作员编码或者机构号
            String operatorCode = PaperlessConfig.operatorCode;
            // 机构编码
            String channelCode = PaperlessConfig.channelCode;

            //获取上传结果
            String result = clientBean.uploadSealLog(PaperlessUtil.buildSealLogsXml(sealLogBeans), operatorCode, channelCode);

            String code = StringUtil.getNodeText(result, "Code");

            if ("200".equals(code)) {
                System.out.println(result);
                System.out.println("OK:uploadSealLog");
            } else {
                System.out.println("NG:uploadSealLog");
                // 处理结果为异常，打印出错误码和错误信息
                System.out.println(result);
            }
            

        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
